<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/head :: head(links)"/>
<body>
<div class="ok-body" id="app" v-cloak>
    <template>
        <i-form label-colon ref="checkForm" :model="entity" :rules="ruleValidate" :label-width="140">
            <form-item prop="mchId" label="商户号">
                <i-input  maxlength="20" v-model="entity.mchId" placeholder="请输入商户号"></i-input>
            </form-item>

            <form-item prop="secretKey" label="秘钥">
                <i-input  v-model="entity.secretKey" placeholder="请输秘钥"></i-input>
            </form-item>
        </i-form>
    </template>
</div>
<div th:replace="common/foot :: foot(script)"></div>
<script th:inline="none">
var vm = new Vue({
    el: '#app',
    data:{
        entity:{

        },
        ruleValidate : {
			mchId: [
				{ required: true, message: '不能为空', trigger: 'blur' }
			],
			secretKey: [
				{ required: true, message: '不能为空', trigger: 'blur'}
			],
		},
		okUtils:null,
		okLayer:null
    },
    methods: {
        load : function(){
            layui.use(["okUtils", "okLayer"], function () {
                 vm.okUtils = layui.okUtils;
                 vm.okLayer = layui.okLayer;
                 if(vm.entity.carParkId!=undefined){
                     vm.okUtils.ajaxCloud({
                        url:"/pay/config/getByCarParkId",
                        param : {carParkId:vm.entity.carParkId},
                        close : false,
                        success : function(result) {
                            if(result.msg!=null){
                                vm.entity = result.msg;
                            }
                        }
                     });
                 }
            });
	    },
        acceptClick : function(dialog){
          vm.$refs.checkForm.validate(function(valid){
            if (valid) {
                 vm.okUtils.ajaxCloud({
                    url:"/pay/config/save",
                    param : vm.entity,
                    json:true,
                    success : function(result) {
                        vm.okLayer.msg.greenTick(result.msg)
                        dialog.load();
                    }
                 });
            }
          });
	    },
    },
    created: function() {

    }
});
</script>
</body>
</html>